package gl.j2ee.jfinal;


import java.io.File;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;

public class MyBaseConfig extends JFinalConfig{
	public  static  String FILEDB = "doc.DB";
	public  static  File TEMPDIR = new File(("/temp/"));
	@Override
	public void configConstant(Constants arg0) {
		arg0.setDevMode(true); 
		System.getProperty("user.dir");
		try {
			FILEDB = new File(getClass().getResource("/").getPath()).getParentFile().getParentFile().getParent()+File.separator+FILEDB;
			System.out.println("filedb:"+FILEDB);
			String tempdirString = new File(getClass().getResource("/").getPath()).getParentFile().getParent()+File.separator+"/temp/";
			File tempdir = new File(tempdirString);
			if (!tempdir.exists()) {
				tempdir.mkdirs();
			}
			TEMPDIR=tempdir;
			System.out.println("temp  dir:"+TEMPDIR.getAbsolutePath());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	public static void main(String[] args) {
		System.out.println(new File(Object.class.getClass().getResource("/").getPath()));
	}
	@Override
	public void configHandler(Handlers arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configInterceptor(Interceptors arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configPlugin(Plugins arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configRoute(Routes arg0) {
		arg0.add("/", MainController.class,"/");
		System.out.println("configRoute"+"/");
		
		
	}
}

